﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PSLib.CodeFormating.Lexems;

namespace PSLib.CodeFormating.Formatters
{
	[Serializable]
	public class LexemConfigurationCollection : IEnumerable<LexemConfiguration>
	{
		public LexemConfigurationCollection()
		{
			collection = new Dictionary<LexemType, LexemConfiguration>();
		}

		public void Add(LexemConfiguration settings)
		{
			collection.Add(settings.LexemType, settings);
		}

		public bool Contains(LexemType type)
		{
			return collection.ContainsKey(type);
		}

		public LexemConfiguration this[LexemType key]
		{
			get { return collection[key]; }
			set { collection[key] = value; }
		}

		#region IEnumerable<LexemSettings> Members

		public IEnumerator<LexemConfiguration> GetEnumerator()
		{
			return collection.Values.GetEnumerator();
		}

		#endregion

		#region IEnumerable Members

		System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
		{
			return collection.Values.GetEnumerator();
		}

		#endregion

		Dictionary<LexemType, LexemConfiguration> collection;
	}
}
